// 部门 人员 审核表格表格配置
import StateStore from '@/components/ivew_conf/state_store'
import {formatDate} from '@/utils/tools'
import format_car_upfile_list from '../../service/middleware_fns/format_car_upfile_list';
import auditingStatusConf from '@/components/ivew_conf/auditing/auditing_status_conf'
const auditingPersonalLable = () => import('@/components/ivew_components/table_label_compoents/auditing_personal.vue')


const auditingStatusStore = new StateStore(auditingStatusConf)


// 复制内容
function copy(key:string):any{
    return function(h, {row, column, index}){
        let val = row[key];
        return h('c-copy-txt-label',[val])
    }
}

const conf = [
    {
      title: '#',
      type: 'index',
      width: 60, 
    },
    {
        title: '申请类型',
        width: 160,
        key: '_describe',
        render(h, {row, column, index}){
            let {action, type}  = row['_describe'];
            let formData = row.jsonData;
            let name =  formData.name || formData.nickname;
            
            let content = [

                h('Tag', {
                    props:{
                        color: action.color
                    },
                    style:{
                        display: 'inline-block'
                    }
                }, [action.label]),

                h('Tag',{
                    props:{
                        color: type.color
                    }
                }, [type.label]),

            ]
            
            return h('div', {}, [content])

        }
    },
    {
        title: '信息名称',
        width: 160,
        ellipsis: true,
        render(h, {row, column, index}){
            let formData = row.jsonData;
            let name =  formData.nickname || formData.name;

            return h('div', {}, [name])

            
        }
    },
    {
        title: '申请人',
        width: 160,
        key: 'createdBy',
        render (h, {row, column, index}){

            let createdBy = row['createdBy'];

            
            return h(auditingPersonalLable, {
                props: {
                    ...createdBy
                }
            })
        }
    },
    {
        title: '审核人',
        width: 160,
        key: 'checkedBy',
        render (h, {row, column, index}){

            let checkedBy = row['checkedBy'];

            
            return h(auditingPersonalLable, {
                props: {
                    ...checkedBy
                }
            })
        }
    },
    {
        title: '审核时段',
        key: 'checkedTime',
        width: 110,
        align: 'center',
        render (h, {row, column, index}){

            let createdTime = formatDate(new Date(row['createdTime']));
            let checkedTime = formatDate(new Date(row['checkedTime']))
            
            let  timeContainer = [
                h('h4', {style: {fontSize: '.8rem', fontWeight: 400}},[createdTime]),
                h('h4', {style: {fontSize: '.8rem',  fontWeight: 400}},[checkedTime])
            ]
            
            return h('div', {
                style: {
                    color: '#a0adc9',
                }
            },[
                timeContainer
            ])
            
        }
    },
    {
        title: '审核信息ID',
        key: 'id',
        minWidth: 320,
        render: copy('id')
    },
    {
        title: '审核状态',
        key: 'result',
        width: 120,
        align: 'center',
        fixed: 'right',
        render (h, {row, column, index}){
            
            return h ('c-status-label', {

                props: {
                    val: auditingStatusStore.getVal(row['result'])
                }

            })
            
        }

    },
    
    
     
];


export default conf